def solve(n, k, A):
    # 从大到小排序
    A.sort(reverse=True)  # 改为降序排序
    # 计算前缀和 s[0]=0, s[1]=a[0]

    if n <= k:
        return -1
    
    s = [0] * (n + 1)
    for i in range(n):
        s[i + 1] = s[i] + A[i]
    
    #二分i
    left, right = 0, n - k - 1
    result = -1
    
    while left <= right:
        i = (left + right) // 2
        remaining = n - i
        if remaining <= k:
            right = i - 1
            continue
        s_hua = s[i + k] - s[i]
        s_ming = s[n] - s[i + k]
        
        if s_ming > s_hua:
            result = i
            right = i - 1
        else:
            left = i + 1 
    
    return result

n, k = map(int, input().split())
A = list(map(int, input().split()))

print(solve(n, k, A))